登录 白背景

2582. 递枕头

https://leetcode.cn/problems/pass-the-pillow/description

  • 难度:简单
  • 提交时间:2023.10.30 20:08
  • 0ms 击败 100.00%使用 Go 的用户
  • 1.76MB 击败 1.51%使用 Go 的用户

func passThePillow(n int, time int) int {
    time++
    time2 := time % (2*n - 2)
    if time2 == 0 {
        return 2
    }
    if time2 < n {
        return time2
    }
    return n*2 - time2
}